import {filterData2} from '@/static/js/filter.js';
import uSwipeActionItem from "@/components/uni-swipe-action-item/uni-swipe-action-item.vue";
import uniSwipeAction from "@/components/uni-swipe-action/uni-swipe-action.vue";
export default{
	data(){
		return {
			pageIndex: 1,
			pageSize: 10,
			list: null,
			options: [{
				text: '删除',
				style: {
					backgroundColor: '#EE2437' // 删除按钮背景  红的
				}
			}],
			page:1,
			deleteList:'',
			nullData: false,
		}
	},
	onBackPress(e){
		uni.reLaunch({
			url:'/pages/index/index'
		})
		return true
		
	},
	onLoad(){
		this.getlist({pageIndex:this.pageIndex,pageSize:this.pageSize})
	},
	onReachBottom() {
		if(this.nullData == true){
			return;
		}
		this.page = this.page + 1
		this.getlist({pageIndex:this.pageIndex,pageSize:this.pageSize})
	},
	methods:{
		filterData2,
		getlist(data){
			this.$api.UserInfolist(data).then((res)=>{
				var data = res.data.result.list.map((a)=> {
					a.updateTime = a.updateTime;
					return a
				});
				if(this.deleteList == 1) {
					this.list = []
					this.list = data
					this.deleteList = ''
				}else {
					this.list = this.list ? this.list.concat(data) : data
				}
				if(this.list.length >= res.data.result.totalCount){
					this.nullData = true;
				}
			})
		},
		toView(e) {
		   if(e.status == 1) {
		    uni.navigateTo({
		     url:'/pages/monitor/information/information?id='+e.id
		    })
		   } else if(e.status == 2) {
		    uni.navigateTo({
		     url:'/pages/monitor/information/toView?id='+e.id
		    })
		   }
		 },
		bindClick(e) {
			const id = e.id;
			this.$api.UserinforDeleteId(id).then((res) => {
				if(res.data.returnCode == '200') {
					uni.showToast({
						title: '删除成功',
						icon: 'none'
					})
					this.page = 1
					this.deleteList = 1;
					this.nullData = false;
					this.getlist({pageIndex:this.pageIndex,pageSize:this.pageSize})
				}
			})
		}
	}
}